
*	**********************************************************************	*
*	This file replicates Tables in											*
*	Yang "Bring Your Own Workers"											*
*	World Development														*
*	**********************************************************************	*

use "replication_WD_BringYourOwnWorkers", clear

xtset cowcode year 
gen contractworkersL1=L1.contractworkers
gen laborconditionL1=L1.laborcondition
gen ip_laborconditionL1=L1.ip_laborcondition
gen il_laborconditionL1=L1.il_laborcondition
gen totalinvestL1=L1.totalinvest
gen ln_OFDI_flow=ln(OFDI_flow+1000)
gen ln_OFDI_flow_L1=L1.ln_OFDI_flow
gen ofdi_inflow_gdp=(ofdi_inflow/GDP)*1000000
gen ofdi_inflow_gdp_L1=L1.ofdi_inflow_gdp



gen ContractRevenueL1=L1.ContractRevenue
gen delta_ContractRevenue=ContractRevenue -ContractRevenueL1
gen delta_ContractRevenue_L1=L1.delta_ContractRevenue
gen ln_delta_ContractRevenue=ln(3000+delta_ContractRevenue )
gen ln_delta_ContractRevenue_L1=L1.ln_delta_ContractRevenue
gen laborconditionL1_bi=laborconditionL1


gen laborconditionL1_bi=laborconditionL1
replace laborconditionL1_bi =1 if laborconditionL1_bi >0


*table 1. Chinese FDI project and Chinese expatriate workeres"

xtnbreg contractworkers c.laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra    i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra BIT   taiwan diplomatic_year  diplomatic_represent lndist i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra  BIT  taiwan diplomatic_year  diplomatic_represent  lndist time, re /*random effect*/
xtnbreg contractworkers contractworkersL1 c.laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp FDI tradeopen socialistlegacies fe_etfra  BIT  taiwan diplomatic_year  diplomatic_represent lndist i.year,fe
margins, dydx(totalinvestL1) at(laborcondition=(0(2)10) )

*table 2. Chinese FDI flow and Chinese expatriate workeres"

xtnbreg contractworkers c.laborconditionL1##c.ln_OFDI_flow_L1  polity2  lngdppc lnGDP GDPgrowth i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.ln_OFDI_flow_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra    i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.ln_OFDI_flow_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra BIT   taiwan diplomatic_year  diplomatic_represent lndist i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.ln_OFDI_flow_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra  BIT  taiwan diplomatic_year  diplomatic_represent  lndist time, re /*random effect*/
xtnbreg contractworkers contractworkersL1 c.laborconditionL1##c.ln_OFDI_flow_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp FDI tradeopen socialistlegacies fe_etfra  BIT  taiwan diplomatic_year  diplomatic_represent lndist i.year,fe
margins, dydx(ln_OFDI_flow_L1) at(laborcondition=(0(2)10) )


*table 2. Chinese FDI inflow and Chinese expatriate workeres"

xtnbreg contractworkers c.laborconditionL1##c.ofdi_inflow_gdp_L1  polity2  lngdppc lnGDP GDPgrowth i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.ofdi_inflow_gdp_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra    i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.ofdi_inflow_gdp_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra BIT   taiwan diplomatic_year  diplomatic_represent lndist i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.ofdi_inflow_gdp_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra  BIT  taiwan diplomatic_year  diplomatic_represent  lndist time, re /*random effect*/
xtnbreg contractworkers contractworkersL1 c.laborconditionL1##c.ofdi_inflow_gdp_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp FDI tradeopen socialistlegacies fe_etfra  BIT  taiwan diplomatic_year  diplomatic_represent lndist i.year,fe
margins, dydx( ofdi_inflow_gdp_L1) at(laborcondition=(0(2)10) )
marginsplot,yscale(alt) yline(0) recast(line) plotopts(lw(medthick)) recastci(rline) ciopts(lp(dash)) addplot(histogram laborconditionL1,percent yaxis(2) fcolor(none) lcolor(grey)) level(95) legend(off) graphregion(color(white)) title ("Marginal Effect of Chinese OFDI inflow on Chinese Workers in Africa")


xtnbreg contractworkers c.laborconditionL1##c.ln_ofdi_inflow_L1 polity2 lnGDP lngdppc GDPgrowth  i.year ,fe
xtnbreg contractworkers c.laborconditionL1##c.ln_ofdi_inflow_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra    i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.ln_ofdi_inflow_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra BIT   taiwan diplomatic_year  diplomatic_represent lndist i.year,fe 
xtnbreg contractworkers c.laborconditionL1##c.ln_ofdi_inflow_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra  BIT  taiwan diplomatic_year  diplomatic_represent  lndist time, re /*random effect*/
xtnbreg contractworkers contractworkersL1 c.laborconditionL1##c.ln_ofdi_inflow_L1polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp FDI tradeopen socialistlegacies fe_etfra  BIT  taiwan diplomatic_year  diplomatic_represent lndist i.year,fe


**************************************************************
*Table A1: Diff Measure of Labor Condition (in law labor condition)
**************************************************************
*model(1) projects * random effect
xtnbreg contractworkers c.il_laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT  taiwan diplomatic_year  diplomatic_represent lndist time,re
*model(2) projects * fixed effect
xtnbreg contractworkers c.il_laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe
*model(3) projects * fixed effect * LDV
xtnbreg contractworkers contractworkersL1 c.il_laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe
*model(4) OFDI flow * random effect
xtnbreg contractworkers c.il_laborconditionL1##c.ln_OFDI_flow_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT  taiwan diplomatic_year diplomatic_represent lndist time,re
*model(5) OFDI flow * fixed effect
xtnbreg contractworkers c.il_laborconditionL1##c.ln_OFDI_flow_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe
*model(6) OFDI flow * fixed effect * LDV
xtnbreg contractworkers contractworkersL1 c.il_laborconditionL1##c.ln_OFDI_flow_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe

*model(4) OFDI flow * random effect
xtnbreg contractworkers c.il_laborconditionL1##c.ofdi_inflow_gdp_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra BIT  taiwan diplomatic_year  diplomatic_represent lndist time,re
*model(5) OFDI flow * fixed effect
xtnbreg contractworkers c.il_laborconditionL1##c.ofdi_inflow_gdp_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe
*model(6) OFDI flow * fixed effect * LDV
xtnbreg contractworkers contractworkersL1 c.il_laborconditionL1##c.ofdi_inflow_gdp_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe




**************************************************************
*Table A2: Diff Measure of Labor Condition (in practice labor condition)
**************************************************************
*model(1) projects * random effect
xtnbreg contractworkers c.ip_laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT  taiwan diplomatic_year  diplomatic_represent lndist time,re
*model(2) projects * fixed effect
xtnbreg contractworkers c.ip_laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe
*model(3) projects * fixed effect * LDV
xtnbreg contractworkers contractworkersL1 c.ip_laborconditionL1##c.totalinvestL1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe
*model(4) OFDI flow * random effect
xtnbreg contractworkers c.ip_laborconditionL1##c.ln_OFDI_flow_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT  taiwan diplomatic_year diplomatic_represent lndist time,re
*model(5) OFDI flow * fixed effect
xtnbreg contractworkers c.ip_laborconditionL1##c.ln_OFDI_flow_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe
*model(6) OFDI flow * fixed effect * LDV
xtnbreg contractworkers contractworkersL1 c.ip_laborconditionL1##c.ln_OFDI_flow_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe
*model(4) OFDI flow * random effect
xtnbreg contractworkers c.ip_laborconditionL1##c.ofdi_inflow_gdp_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra BIT  taiwan diplomatic_year  diplomatic_represent lndist time,re
*model(5) OFDI flow * fixed effect
xtnbreg contractworkers c.ip_laborconditionL1##c.ofdi_inflow_gdp_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe
*model(6) OFDI flow * fixed effect * LDV
xtnbreg contractworkers contractworkersL1 c.ip_laborconditionL1##c.ofdi_inflow_gdp_L1  polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen  socialistlegacies fe_etfra BIT taiwan diplomatic_year  diplomatic_represent lndist i.year ,fe


***********************************************************************
*Table A5: binary data
*************************************************

xtnbreg contractworkers c.laborconditionL1_bi##c.totalinvestL1  polity2 lnGDP lngdppc GDPgrowth i.year ,fe
xtnbreg contractworkers c.laborconditionL1_bi##c.totalinvestL1  polity2 lnGDP lngdppc GDPgrowth i.year if year>2008,fe
xtnbreg contractworkers contractworkersL1  c.laborconditionL1_bi##c.totalinvestL1    polity2  lngdppc lnGDP GDPgrowth  i.year if year>2008 , fe


xtnbreg contractworkers  c.laborconditionL1_bi##c.ofdi_inflow_gdp_L1 polity2 lnGDP lngdppc GDPgrowth i.year ,fe
xtnbreg contractworkers c.laborconditionL1_bi##c.ofdi_inflow_gdp_L1 polity2 lnGDP lngdppc GDPgrowth i.year if year>2008,fe
xtnbreg contractworkers contractworkersL1  c.laborconditionL1_bi##c.ofdi_inflow_gdp_L1   polity2  lngdppc lnGDP GDPgrowth  i.year if year>2008 , fe





*************************************************************
*Table A6: revenue change									*
*************************************************************
xtnbreg contractworkers c.laborconditionL1##c.ln_delta_ContractRevenue_L1 polity2  lngdppc lnGDP GDPgrowth    i.year,fe
xtnbreg contractworkers c.laborconditionL1##c.ln_delta_ContractRevenue_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra     i.year,fe
xtnbreg contractworkers c.laborconditionL1##c.ln_delta_ContractRevenue_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra   BIT  taiwan diplomatic_year  diplomatic_represent lndist i.year,fe
xtnbreg contractworkers contractworkersL1 c.laborconditionL1##c.ln_delta_ContractRevenue_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra   BIT  taiwan diplomatic_year  diplomatic_represent lndist  i.year,fe

*************************************************************
xtnbreg contractworkers c.laborconditionL1##c.delta_ContractRevenue_L1 polity2  lngdppc lnGDP GDPgrowth    i.year,fe
xtnbreg contractworkers c.laborconditionL1##c.delta_ContractRevenue_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra     i.year,fe
xtnbreg contractworkers c.laborconditionL1##c.delta_ContractRevenue_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra   BIT  taiwan diplomatic_year  diplomatic_represent lndist i.year,fe
xtnbreg contractworkers contractworkersL1 c.laborconditionL1##c.delta_ContractRevenue_L1 polity2  lngdppc lnGDP GDPgrowth  NaturalRen Unemp  FDI tradeopen socialistlegacies fe_etfra   BIT  taiwan diplomatic_year  diplomatic_represent lndist  i.year,fe







use "UNIDO_replication", clear



*main model
nbreg foreignemployee   i.ChinaFirm##c.laborcondition   i.countries
nbreg foreignemployee   i.ChinaFirm##c.laborcondition firmsize  primary tertiary  firmyear skilledLaborImportance subcontractor greenfield embassy  i.countries
nbreg foreignemployee   i.ChinaFirm##c.laborcondition  firmsize primary tertiary  firmyear skilledLaborImportance subcontractor greenfield embassy polity2 lnGDP lngdppc GDPgrowth NaturalRent  Unemployment  i.countries
nbreg foreignemployee   i.ChinaFirm##c.laborcondition  firmsize primary tertiary  firmyear skilledLaborImportance subcontractor greenfield embassy polity2 lnGDP lngdppc GDPgrowth NaturalRent  Unemployment  




**************************
*regression model with labor condition DJ
nbreg foreignemployee  i.ChinaFirm##c.laborconditionDJ   i.country_
nbreg foreignemployee  i.ChinaFirm##c.laborconditionDJ  firmsize primary tertiary  firmyear skilledLaborImportance subcontractor greenfield embassy  i.countries
nbreg foreignemployee  i.ChinaFirm##c.laborconditionDJ  firmsize primary tertiary  firmyear skilledLaborImportance subcontractor greenfield embassy polity2 lnGDP lngdppc GDPgrowth NaturalRent  Unemployment i.countries
nbreg foreignemployee  i.ChinaFirm##c.laborconditionDJ  firmsize primary tertiary  firmyear skilledLaborImportance subcontractor greenfield embassy polity2 lnGDP lngdppc GDPgrowth NaturalRent  Unemployment  

*regression model with labor condition IP
nbreg foreignemployee  i.ChinaFirm##c.laborconditionIP   i.countries
nbreg foreignemployee  i.ChinaFirm##c.laborconditionIP  firmsize  primary tertiary  firmyear skilledLaborImportance subcontractor greenfield embassy  i.countries
nbreg foreignemployee  i.ChinaFirm##c.laborconditionIP  firmsize primary tertiary  firmyear skilledLaborImportance subcontractor greenfield embassy polity2 lnGDP lngdppc GDPgrowth NaturalRent  Unemployment   i.countries
nbreg foreignemployee  i.ChinaFirm##c.laborconditionIP  firmsize primary tertiary  firmyear skilledLaborImportance subcontractor greenfield embassy polity2 lnGDP lngdppc GDPgrowth NaturalRent  Unemployment  






